Title: SQL BT (By-BKK) / 13 Insert
Tags: Obsidian_to_Anki

Q: What is a schema in SQL?
A: A schema describes the structure of a table and the data types for each column.

Q: What ensures efficiency and consistency in a database with millions of rows?
A: Having a fixed structure for tables, defined by the schema.

Q: True/False: The values in each column of a SQL table can be of any data type.
A: False. Each column must have values matching its specified data type.

Q: What SQL statement is used to add new data to a table?
A: INSERT statement

Q: How do you insert data into all columns of a table in SQL?
A: Use INSERT INTO table VALUES (value1, value2, …);

Q: What should you do if you have incomplete data and want to insert a row in SQL?
A: Specify only the columns you have data for using INSERT INTO table (column1, column2) VALUES (value1, value2);

Q: True/False: You must match the number of values to the number of columns specified in an INSERT statement.
A: True

Q: Why is it beneficial to specify columns explicitly in an INSERT statement?
A: It allows forward compatibility if new columns are added to the table.

Q: Can you insert multiple rows in a single SQL INSERT statement?
A: Yes, by listing each row’s values sequentially in parentheses.

Q: What type of expressions can you use when inserting data in SQL?
A: Mathematical and string expressions.

Q: Give an example of using an expression in an INSERT statement.
A: INSERT INTO boxoffice (movie_id, rating, sales_in_millions) VALUES (1, 9.9, 283742034 / 1000000);

Q: Reverse card example:
A schema describes the structure and data types of a SQL table.
What is a schema in SQL?
A: You can insert data with only some columns specified.
What should you do if you have incomplete data when inserting in SQL? #flashcard

Q: Mathematical and string expressions can be used in INSERT statements.
What type of expressions can you use while inserting data in SQL?
A: You must match the number of values to the number of columns specified in the INSERT statement.
True/False: The number of values can be different from the number of columns when inserting in SQL. #flashcard

Q: Tables can have default values for some columns.
Why can you sometimes omit certain columns when using INSERT in SQL?
A: Having a fixed structure and data types in SQL makes the database efficient and consistent.
How does schema design affect database efficiency and consistency? #flashcard